<template>
  <header class="head-nav">
    <div class="logo-container">
      <img src="@/assets/logo.png" class="logo" alt="" />
      <span class="title">Toy Backstage System</span>
    </div>
    <div class="user">
      <div class="userinfo">
        <div class="welcome">
          <p class="name avatarname">{{ user.name }}</p>
        </div>
        <span class="username">
          <el-dropdown trigger="click" @command="setDialogInfo">
            <span class="el-dropdown-link">
              <i class="el-icon-caret-bottom el-icon--right"></i>
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item command="logout">退出</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </span>
      </div>
    </div>
  </header>
</template>
<script>
export default {
  name: "head-nav",
  computed: {
    user() {
      return {
        avatar: "",
        name: "admin",
      };
    },
  },
  methods: {
    setDialogInfo(cmditem) {
      switch (cmditem) {
        case "logout":
          this.logout();
          break;
      }
    },
    logout() {
      // 清除token
      // 页面跳转
      this.$router.push("/login");
    },
  },
};
</script>

<style lang="scss" scoped>
.head-nav {
  width: 100%;
  height: 100px;
  min-width: 600px;
  box-sizing: border-box;
  color: #fff;
  border-bottom: 1px solid #1f2d3d;
  padding-top: 20px;
  display: flex;
  justify-content: space-between;
  background: url(./../../assets/image/header.png) no-repeat;
  background-size: 100% 100%;
  .logo-container {
    line-height: 60px;
    min-width: 400px;
  }
  .logo {
    height: 40px;
    width: 40px;
    margin-left: 30px;
    margin-right: 20px;
    vertical-align: middle;
    display: inline-block;
  }
  .title {
    vertical-align: middle;
    font-size: 20px;
    font-family: "Microsoft YaHei";
    letter-spacing: 3px;
  }
  .user {
    line-height: 60px;
    text-align: right;
    padding-right: 20px;
    box-sizing: border-box;
    .welcome {
      display: inline-block;
      width: auto;
      vertical-align: middle;
      padding: 0 5px;
      box-sizing: border-box;
    }
    .name {
      line-height: 20px;
      text-align: center;
      font-size: 14px;
    }
    .avatarname {
      font-size: 16px;
      color: #fff;
      font-weight: bolder;
    }
    .username {
      cursor: pointer;
      margin-right: 5px;
    }
    .el-dropdown {
      color: #fff;
    }
  }
}
</style>
